$(function(){
    initData();
})
/*初始化数据*/
function initData(){
    var selected = $("#dictTable").bootstrapTable('getSelections');
    var selected_length = selected.length;
    if (!selected_length) {$JuXue.n_warning('请勾选需要修改的用户！');return;}
    if (selected_length > 1) {$JuXue.n_warning('一次只能修改一个用户！');return;}

    var dictId = selected[0].dictId;
    $.post(ctx + "dict/getDict", {"dictId": dictId}, function (r) {
        if (r.code === 0) {
            var dict = r.msg;
            $("#keyy").val(dict.keyy);
            $("#valuee").val(dict.valuee);
            $('#tableName').val(dict.tableName);
            $('#fieldName').val(dict.fieldName);
            $("#dictId").val(dictId);
        } else {
            $JuXue.n_danger(r.msg);
        }
    });
}

function updateDict() {
    var selected = $("#dict-edit-form").bootstrapTable("getSelections");
    var dict = $("#dict-edit-form").serialize();
    $.post(ctx + "dict/update",dict,function(r){
        if(r.code===0){
            $("#dict-info").modal('hide');
            $JuXue.n_success(r.msg);
            $JuXue.refreshTable("dictTable");
        }else{
            $JuXue.n_danger(r.msg);
        }
    })
}